<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>设置盒子居中</title>
    <style>
    div{
        width:100px;
        height:100px;
        background-color:red;
        /* text-align:center;设置文本居中 */
     /*   margin-top:auto;
        margin-bottom:auto;*/
        margin-left:auto;
        margin-right:auto;
    }
    </style>
</head>
<body>
    <div> </div>
</body>
</html>